#include <bits/stdc++.h>
// 2025/02/06
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

const int maxn = 10001;

int n, m, k, l[maxn], r[maxn], x[maxn], y[maxn];
int64 dp[maxn][1001], ans;

signed main()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i], l[i + 1] = r[i + 1] = INT_MIN;
    for (int i = 1, p; i <= k; i++)
        cin >> p, cin >> l[p] >> r[p];
    for (int i = 1; i <= n; i++)
        dp[i][0] = 1e15;
    for (int i = 1; i <= n; i++){
        ans = 1e15;
        for (int j = 1; j <= m; j++)
            dp[i][j] = 1e15;
        for (int j = x[i - 1] + 1; j < m; j++)
            dp[i][j] = min(dp[i][j], min(dp[i - 1][j - x[i - 1]], dp[i][j - x[i - 1]]) + 1);
        for (int j = m - x[i - 1]; j <= m; j++)
            dp[i][m] = min(dp[i][m], min(dp[i - 1][j], dp[i][j]) + 1);
        for (int j = 1; j <= m - y[i - 1]; j++)
            dp[i][j] = min(dp[i][j], dp[i - 1][j + y[i - 1]]);
        if (l[i] != INT_MIN){
            for (int j = 1; j <= l[i]; j++)
                dp[i][j] = 1e15;
            for (int j = r[i]; j <= m; j++)
                dp[i][j] = 1e15;
        }
        for (int j = 1; j <= m; j++)
            ans = min(ans, dp[i][j]);
        if (ans == 1e15){
            int cnt = 0;
            for (int j = 1; j < i; j++)
                if (l[j] != INT_MIN)
                    cnt++;
            cout << 0 << endl << cnt;
            return 0;
        }

    }
    cout << 1 << endl << ans;
    return 0;
}